function Window()
{
	this.commonPop = popWin;
	
}

function popWin(theURL,winName,theW,theH,showAsModal) {
    theTop = (window.screen.height-theH)/2;
    theLeft = (window.screen.width-theW)/2;
    var features = "toolbar=0,scrollbars=yes,left=" + theLeft + ",top=" + theTop + ",width=" + theW + ",height=" + theH;
    
    window.SubWin = window.open(theURL,winName,features);
    window.SubWin.focus();
    
    if(showAsModal){
        window.CtrlsDisabled = new Array();
        DisableCtrls("INPUT;SELECT;TEXTAREA;BUTTON");
    }

    function DisableCtrls(tagNameStr){
        var arrTags = tagNameStr.split(";");
        for(var i=0;i<arrTags.length;i++){
            var arrEle = document.getElementsByTagName(arrTags[i]);
            PushToCtrlsDisabled(arrEle);
        }

        for(var i=0;i<window.CtrlsDisabled.length;i++){
            window.CtrlsDisabled[i].disabled = true;
            window.CtrlsDisabled[i].readOnly = true;
        }
    }

    function PushToCtrlsDisabled(arrEle){
        for(var i=0;i<arrEle.length;i++){
            if(!arrEle[i].disabled){
                window.CtrlsDisabled.push(arrEle[i]);
            }
        }
    }
    
    window.onfocus = function(){
        if(window.SubWin && showAsModal){
            if(window.SubWin.closed == true || typeof(window.SubWin.closed) == "undefined"){
                for(var i=0;i<window.CtrlsDisabled.length;i++){
                    window.CtrlsDisabled[i].disabled = false;
                    window.CtrlsDisabled[i].readOnly = false;
                }
            }else{
                window.SubWin.focus();
            }
        }
    }
}